package cn.xjt.IOinputStream;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import org.junit.Test;

public class TestBufferedWrite {
	@Test
	public void testBufferedWrite()
	{
		BufferedWriter write = null;
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader("src/test/copyArraytext.txt"));
			write = new BufferedWriter(new FileWriter("src/test/File.txt"));
			char[] c= new char[1024];
			int lenght = -1;
			String str = reader.readLine();
			System.out.println(str);
			while((lenght = reader.read(c))!=-1)
			{
				write.write(c,0,lenght);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			try {
				if(reader!=null)
					reader.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				if(write!=null)
					write.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
